package it.unibz.ti2.internetPizzeria.webAttributes;

import java.util.ArrayList;
import java.util.List;

import it.unibz.ti2.internetPizzeria.entities.Drink;
import it.unibz.ti2.internetPizzeria.entities.Order;
import it.unibz.ti2.internetPizzeria.entities.OrderProduct;
import it.unibz.ti2.internetPizzeria.entities.Pizza;
import it.unibz.ti2.internetPizzeria.entities.Product;

/**
 * Class containing all necessary information about Order used on jsp pages to
 * present order details
 */
public class OrderInfo {

	private Order order;

	private List<OrderProduct> pizzas;

	private List<OrderProduct> drinks;

	/**
	 * Creates new OrderInfo object basing on specified order. Separates
	 * orderProduct list into two different lists for pizzas and drinks.
	 * 
	 * @param order
	 */
	public OrderInfo(Order order) {
		this.order = order;
		this.pizzas = new ArrayList<OrderProduct>();
		this.drinks = new ArrayList<OrderProduct>();
		for (OrderProduct orderProduct : this.order.getOrderProducts()) {
			Product product = orderProduct.getProduct();
			if (product.getClass().equals(Pizza.class)) {
				this.pizzas.add(orderProduct);
			} else if (product.getClass().equals(Drink.class)) {
				this.drinks.add(orderProduct);
			}
		}
	}

	public List<OrderProduct> getDrinks() {
		return drinks;
	}

	public Order getOrder() {
		return order;
	}

	public List<OrderProduct> getPizzas() {
		return pizzas;
	}

}
